<?php

use app\components\BaseGridView;
use app\helpers\UserHelper;
use app\models\User;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;

/* @var $dataProvider */

?>

<div class="mb-2">
    <?= Html::a('添加用户', ['user/save'], ['class' => 'btn']); ?>

    <div class="search pull-right">
        <form class="form-inline" action="/index.php" method="get">
            <input type="hidden" name="r" value="user/index">
            <div class="form-group">
                <label>用户识别号</label>
                <input type="text" value="<?= Yii::$app->request->get('imsi') ?>" name="imsi" class="form-control">
            </div>
            <div class="form-group">
                <label>用户号码</label>
                <input type="text" value="<?= Yii::$app->request->get('phone') ?>" name="phone" class="form-control">
            </div>
            <button type="button" class="btn btn-info btn-search">搜索</button>
        </form>
    </div>
</div>

<div class="btn-toolbar mb-2">
    <button href="<?= Url::to(['yb', 'v' => 1, 'id' => '']); ?>" class="btn btn-danger disabled">遥毙</button>
    <button href="<?= Url::to(['yb', 'v' => 0, 'id' => '']); ?>" class="btn btn-default disabled">遥毙恢复</button>
    <button href="<?= Url::to(['yy', 'v' => 1, 'id' => '']); ?>" class="btn btn-danger disabled">遥晕</button>
    <button href="<?= Url::to(['yy', 'v' => 0, 'id' => '']); ?>" class="btn btn-default disabled">遥晕恢复</button>
    <button href="<?= Url::to(['gps', 'v' => 1, 'id' => '']); ?>" class="btn btn-danger disabled">GPS跟踪</button>
    <button href="<?= Url::to(['gps', 'v' => 0, 'id' => '']); ?>" class="btn btn-default disabled">GPS跟踪恢复</button>
</div>

<?= BaseGridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => NULL,
    'columns' => [
        ['class' => 'app\components\CheckboxColumn'],
        'phone',
        ['attribute' => 'device_type', 'value' => function (User $model) {
            return ArrayHelper::getValue(UserHelper::$deviceType, $model['device_type']);
        }],
        ['attribute' => 'user_priority', 'value' => function (User $model) {
            return ArrayHelper::getValue(UserHelper::$userPriority, $model['user_priority']);
        }],
        'esn',
        'imsi',
        ['attribute' => 'vo_coder', 'value' => function (User $model) {
            return ArrayHelper::getValue(UserHelper::$voCoder, $model['vo_coder']);
        }],
        [
            'class' => 'app\components\BaseActionColumn',
            'template' => '{save} {delete} {view}',
            'saveOptions' => ['class' => ''],
            'contentOptions' => ['width' => '15%'],
            'buttons' => [
                'view' => function ($url, $model, $key) {
                    $options = [
                        'title' => '查看用户信息',
                        'data-toggle' => 'tooltip',
                        'class' => 'dialog'
                    ];
                    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
                },
            ]

        ]
    ],
]); ?>
